package com.lws.basic.base;

import android.os.Bundle;

import io.reactivex.annotations.Nullable;


/**
 * @松 on 2019/5/13 09:44
 */
public abstract class BaseMvpActivity <P extends BaseMvpPresenter > extends BaseActivity {
    private P mPresenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mPresenter = createPresenter();
        if (mPresenter != null) {
            mPresenter.attachView(this);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.detachView();
            mPresenter = null;
            System.gc();
        }
    }

    protected abstract P createPresenter();
}
